const db = require('./index')


module.exports = {
    getOrder: async (user_id = '') => {
        const sql = `select *,(price*bookCount)as total from book`;
        return await db.query(sql, user_id)
    },
    checkUsername: async (userName) => {
        const sql = `select count(1) as num from users where userName = ? `;
        return await db.query(sql, userName)
    },
    register: async (userName, password) => {
        const sql = ` insert into users values(null,?,?,'18614034312')`;
        return await db.query(sql, [userName, password])
    },
    login: async (userName,password) => {
        const sql = `select * from users where userName = ? and password = ?`;
        return await db.query(sql,[userName,password]);
    }
}